import{k as m,U as u,aS as v,p as w,O as k,N as y,s as d,V as b}from"./DrFvzlh8agutd.js";import{f as r,e as p}from"./DZFz6IIX1esOcA.js";const h=w("sync-assets");function x(t,n){let o=n;const s=u();s.add(()=>o=void 0);const i=r(t);return s.add(d.workspace?.emitter.on("assetDidSync",async e=>{i?.cid===e.cid&&i?.idx===e.idx&&(o&&o(e),s())})),d.workspace?.sync?.requestAssetByUrl(t).then(e=>{e?.bin&&(o&&o(e),s())}),s}function I(t,n){const o=m(),s=u();function i(e){e?s.add(x(e,async c=>{o.value=c,n&&await b(n(c))})):o.value=void 0}return v(t)?(h("watch",t),k(t,i,{immediate:!0}),y(s)):i(t),o}function q(t,n){let o=n;const s=u();s.add(()=>o=void 0);const i=new Set,e=[];function c(a){a&&a.bin&&(e.push(a),i.delete(p(a)),i.size<=0&&(o(e),s()))}s.add(d.workspace?.emitter.on("assetDidSync",c));for(const a of t){const f=r(a);if(f){const l=p(f);i.add(l)}}for(const a of t)r(a)&&d.workspace?.sync?.requestAssetByUrl(a).then(c);return s}export{x as a,q as o,I as u};